﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace Daq.Tools.DEncrypt
{
    public static class MD5Hple
    {
        #region MD5加密服务，字符串内容

        /// <summary>
        /// MD5加密服务，字符串内容
        /// </summary>
        /// <param name="strEncrypt">密码明文</param>
        /// <returns>密码密文</returns>
        public static string ToMd5(this string strEncrypt)
        {
            var strResult = new StringBuilder(1000);
            //var md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
            var md5 = MD5.Create();

            var bEncrypt = Encoding.UTF8.GetBytes(strEncrypt ?? string.Empty);
            var bResult = md5.ComputeHash(bEncrypt);

            foreach (var b in bResult) //十六进制方式输出
            {
                strResult.AppendFormat("{0:X2}", b);
            }
            return strResult.ToString();
        }

        #endregion MD5加密服务，字符串内容
    }
}